<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<fieldset class="layui-elem-field">
    <legend>详细信息</legend>
    <div class="layui-field-box">
        <form class="layui-form">
            <input type="hidden" name="id" value="${plainInfo.ID!''}">

            <div class="layui-form-item">
                <div class="layui-inline">
                    企划编号:${plainInfo.spNo!''}
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">企划名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="spName" placeholder="请输入企划名称" value="${plainInfo.spName!''}"
                               class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">促销条件</label>
                    <div class="layui-input-block">
                        <select name="conNo">
                            <option class="conNo" value="">请选择</option>
                        <#if saleList ? exists>
                            <#list saleList as sale>
                                <option class="conNo" value="${sale.con_no!''}">${sale.con_name!''}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">优惠</label>
                    <div class="layui-input-block">
                        <select name="disNo">
                            <option class="disNo" value="">请选择</option>
                        <#if selectdislist ? exists>
                            <#list selectdislist as dis>
                                <option class="disNo" value="${dis.dis_no!''}">${dis.dis_name!''}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">限额</label>
                    <div class="layui-input-block">
                        <select name="lmtNo">
                            <option class="lmtNo" value="">请选择</option>
                        <#if selectdlmtlist ? exists>
                            <#list selectdlmtlist as lmt>
                                <option class="lmtNo" value="${lmt.lmt_no!''}">${lmt.lmt_name!''}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">代金券</label>
                    <div class="layui-input-block">
                        <select name="cpnNo">
                            <option class="cpnNo" value="">请选择</option>
                        <#if cpnList ? exists>
                            <#list cpnList as cpn>
                                <option class="cpnNo" value="${cpn.cpnNo!''}">${cpn.cpnContent!''}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">活动时间</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input name="startDate" placeholder="开始时间" autocomplete="off"
                               class="layui-input" onclick="layui.laydate({elem: this})"
                               type="text" value="${plainInfo.startDate!''}">
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input name="endDate" placeholder="结束时间" autocomplete="off"
                               class="layui-input" onclick="layui.laydate({elem: this})"
                               type="text" value="${plainInfo.endDate!''}">
                    </div>
                </div>
            </div>




            <div class="layui-form-item">
                <label class="layui-form-label">企划可用</label>
                <div id="isUsed" class="layui-input-block" lay-verify="require">
                    <input type="radio" name="isUsed" value="y" title="可用">
                    <input type="radio" name="isUsed" value="n" title="不可用">
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="updatePlain">确定</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </div>

        </form>
    </div>
</fieldset>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script>
    //Demo
    // 待学生自主完成
    layui.use(['form', 'jquery', 'layer', 'laydate'], function () {
        var $ = layui.jquery;
        var form = layui.form();
        var layer = layui.layer;
        var laydate = layui.laydate;


        //监听修改提交
        form.on('submit(updatePlain)', function (params) {
            var data = $("form").serializeArray();
            $.ajax({
                type: "POST",
                url: "/plain/updatePlainInfo",  //后台程序地址
                data: data,  //需要post的数据
                success: function (data) {           //后台程序返回的标签，比如我喜欢使用1和0 表示成功或者失败
                    if (data.result == 'success') {   //如果成功了, 则关闭当前layer
                        layer.msg('成功', {
                            icon: 1,
                            time: 1000 //1秒关闭（如果不配置，默认是3秒）
                        }, function () {//
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }
                }
            });
            return false;//return false 表示不通过页面刷新方式提交表单
        });


<#-- 回显-->
        var conNo = "${plainInfo.conNo!''}";
        var cpnNo = "${plainInfo.cpnNo!''}";
        var isUsed= "${plainInfo.isUsed!''}";
        var lmtNo = "${plainInfo.lmtNo!''}";
        var disNo = "${plainInfo.disNo!''}";

        $(".conNo[value='" + conNo + "']").attr("selected", true);
        $(".cpnNo[value='" + cpnNo + "']").attr("selected", true);
        $(".lmtNo[value='" + lmtNo + "']").attr("selected", true);
        $(".disNo[value='" + disNo + "']").attr("selected", true);
        $("#isUsed").find("input[value="+isUsed+"]").attr("checked",true);


        form.render();

    });
</script>
</body>
</html>